package com.sky.mapper;

import com.sky.dto.SetmealDTO;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.vo.DishItemVO;
import com.sky.vo.DishVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {

    /**
     * @description: 查询套餐列表
     * @author: tanbobin
     * @date: 2024/6/5 11:03
     * @param:
     * @param setmealDTO
     * @return:
     * @return java.util.List<com.sky.vo.SetmealVO>
     **/
    List<SetmealVO> querySetmealList(SetmealDTO setmealDTO);

    /**
     * @description: 查询套餐关联的菜品信息
     * @author: tanbobin
     * @date: 2024/6/5 11:20
     * @param:
     * @param setmealId
     * @return:
     * @return java.util.List<com.sky.vo.DishVO>
     **/
    @Select("select sd.name, sd.copies, d.image, d.description from setmeal_dish sd left join dish d on sd.dish_id = d.id\n" +
            "    where sd.setmeal_id = #{setmealId}")
    List<DishItemVO> listSetmealByIdWithSetmealDish(Long setmealId);

    /**
     * @description: 修改套餐
     * @author: tanbobin
     * @date: 2024/6/5 16:19
     * @param:
     * @param setmeal
     * @return:
     **/
    void update(Setmeal setmeal);

    /**
     * @description: 根据套餐 id 查询数据
     * @author: tanbobin
     * @date: 2024/6/5 21:10
     * @param:
     * @param id
     * @return:
     * @return com.sky.entity.Setmeal
     **/
    @Select("select * from setmeal where id = #{id}")
    Setmeal getSetmealById(Long id);
}
